package com.supms.course.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.supms.course.domain.TestReview;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.supms.course.domain.CourseTarget;
import com.supms.course.service.ICourseTargetService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 课程目标达成度Controller
 * 
 * @author LiangHao
 * @date 2022-03-11
 */
@RestController
@RequestMapping("/courseTarget")
public class CourseTargetController extends BaseController
{
    @Autowired
    private ICourseTargetService courseTargetService;

    /**
     * 查询课程目标达成度列表
     */
    @RequiresPermissions("course:courseTarget:list")
    @GetMapping("/list")
    public TableDataInfo list(CourseTarget courseTarget)
    {
        startPage();
        List<CourseTarget> list = courseTargetService.selectCourseTargetList(courseTarget);
        return getDataTable(list);
    }

    /**
     * 导出课程目标达成度列表
     */
    @RequiresPermissions("course:courseTarget:export")
    @Log(title = "课程目标达成度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CourseTarget courseTarget)
    {
        List<CourseTarget> list = courseTargetService.selectCourseTargetList(courseTarget);
        ExcelUtil<CourseTarget> util = new ExcelUtil<CourseTarget>(CourseTarget.class);
        util.exportExcel(response, list, "课程目标达成度数据");
    }

    /**
     * 获取课程目标达成度详细信息
     */
    @RequiresPermissions("course:courseTarget:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(courseTargetService.selectCourseTargetById(id));
    }

    /**
     * 新增课程目标达成度
     */
    @RequiresPermissions("course:courseTarget:add")
    @Log(title = "课程目标达成度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CourseTarget courseTarget)
    {
        return toAjax(courseTargetService.insertCourseTarget(courseTarget));
    }

    /**
     * 修改课程目标达成度
     */
    @RequiresPermissions("course:courseTarget:edit")
    @Log(title = "课程目标达成度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CourseTarget courseTarget)
    {
        return toAjax(courseTargetService.updateCourseTarget(courseTarget));
    }

    /**
     * 删除课程目标达成度
     */
    @RequiresPermissions("course:courseTarget:remove")
    @Log(title = "课程目标达成度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(courseTargetService.deleteCourseTargetByIds(ids));
    }

    /**
     * 获取本科课程目标达成度检查表（数据综合查看表）
     */
    @GetMapping("/getCourseTargetTable")
    public CourseTarget getCourseTargetTable(CourseTarget courseTarget)
    {
        return courseTargetService.getCourseTargetTable(courseTarget);
    }
}
